<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 CalenderUI();
 link_js(array('jquery.fixedheader','bootstrap-typeahead'),'asset/js/');
 ?>
<!--<div class='container'>-->
     <div class="tabbable"> <!-- Only required for left/right tabs -->
	<?=$tab_header;?>
       <div class="tab-content" style=''>
	   <br>
            <div class="tab-pane" id="table1"></div>
            <div class="tab-pane active" id="table2"><?=$this->zetro_auth->allAuth($list,'list_customer');?></div></div>
       </div>
		<input type='hidden' id='row_aktif' value='<?=empty($_GET['p'])?'':$_GET['p'];?>'/>
		<input type='hidden' id='rows' value='<?=base64_decode($this->session->userdata('menus'));?>'/>
    </div>
<!--</div>-->
<?=$modal;?>
<script language='javascript'>
$(document).ready(function(e){
	$('div.tab-content').css('height',(screen.availHeight-275));
	$('a#p-table1').live('click',function(){$('#d_Simpan').click();$('#myModal').modal('show');});
	$('#d_Simpan').live('click',function(){$('#frm1:reset').click();$('#myModal').modal('hide');$('a#p-table2').click()});
	$('#b_Simpan').live('click',function(){($('#frm1').validationEngine('validate'))?_simpan_data():'';});
	$('.close').click(function(){ $('#d_Simpan').click();})
	_show_data('');
})
function _show_data(tp)
{
	show_indicator('NewList',6);
	$.post('getlistcustomer','',function(result)
	{
		$('#NewList tbody').html(result);
		(tp=='')?
		$('#NewList').fixedHeader({'width':(screen.availWidth-50),'height':(screen.availHeight-300)}):'';
	})
}
function _simpan_data()
{
	$.post('setcustomer',$('#frm1').serialize(),function(result)
	{
		$('#result').html(result).show().fadeOut(3000);
		_show_data('1');
		$('#d_Simpan').click();
	})
}

function btn_click(id,aksi)
{
	switch(aksi)
	{
		case 'update':
			_show_detail(id);
		break;
		case 'deleted':
		jConfirm('Yakin data ini akan di hapus?','Ziebar Confirm',function(r)
		{
			if(r)
			{
				$.post('deletecustomer',{'id':id},function(result)
				{
					_show_data('1');
				})
			}
		})
		break;	
	}
}
function _show_detail(id)
{
	$.post('getdetailcustomer',{'id':id},
	function(result)
	{
		var r=$.parseJSON(result);
		$('#id_customer').val(r.id_customer)
		$('#id_lokasi').val(r.id_lokasi2).select();
		$('#nm_customer').val(r.nm_customer);
		$('#add_customer').val(r.add_customer);
		$('#telp_customer').val((r.telp_customer));
		$('#telp_customer').val(r.telp_customer);
		$('#cp_customer').val(r.cp_customer);
		$('h4#myModalLabel').html("<i class='cus-cog'></i> Update Customer ");
		$('#myModal').modal('show');	
	})
}
</script>